﻿function SoundPlayer() {
    var that = this;

    soundManager.setup({
        url: '/Scripts/Plugins/SoundManager/',
        onready: function () {
            that.hunterDiedSound = soundManager.createSound({
                id: 'HunterDied',
                url: '/Sounds/HunterDied.mp3'
            });

            that.alienDiedSound = soundManager.createSound({
                id: 'AlienDied',
                url: '/Sounds/AlienDied.mp3'
            });

            that.gameOverSound = soundManager.createSound({
                id: 'GameOver',
                url: '/Sounds/GameOver.mp3'
            });

            that.userJoinedSound = soundManager.createSound({
                id: 'UserJoined',
                url: '/Sounds/UserJoined.mp3'
            });

            that.userLeftSound = soundManager.createSound({
                id: 'UserLeft',
                url: '/Sounds/UserLeft.mp3'
            });

            that.gameStartedSound = soundManager.createSound({
                id: 'GameStarted',
                url: '/Sounds/GameStarted.mp3'
            });
        }
    });
};

SoundPlayer.prototype = (function () {
    return {
        constructor: SoundPlayer,

        hunterDied: function () {
            if (this.hunterDiedSound) {
                this.hunterDiedSound.play();
            }
        },

        alienDied: function () {
            if (this.alienDiedSound) {
                this.alienDiedSound.play();
            }
        },

        gameOver: function () {
            if (this.gameOverSound) {
                this.gameOverSound.play();
            }
        },

        userJoined: function () {
            if (this.userJoinedSound) {
                this.userJoinedSound.play();
            }
        },

        userLeft: function () {
            if (this.userLeftSound) {
                this.userLeftSound.play();
            }
        },

        gameStarted: function () {
            if (this.gameStartedSound) {
                this.gameStartedSound.play();
            }
        }
    };
})();